<template>
  <div class="bonus-config">
    <dt-search ref="search" :xl="6" :xlBtn="6" :label-width="90" @reset="resetFun">
      <Button type="primary" :disabled="list.length == 0" @click="onExport">导出</Button>
    </dt-search>
    <dt-grid ref="table" :columns="columns" :onFetch="onFetch" page />
    <check-modal ref="check" @success="onSuccsse" />
  </div>
</template>
<script>
  import columnOpt from './opt/column.js'
  import SearchOpt from './opt/search.js'
  import extendMgr from '@/biz/bonus/bonusExtend.js'
  import checkModal from '@/views/casemanagement/bonus/deferLog/components/checkModal.vue'
  import moment from 'moment'
  import dt from '@dt/dt'

  export default {
    data() {
      return {
        columns: [],
        filterParams: {},
        list: []
      }
    },
    components: {
      checkModal
    },
    mounted() {
      let retainParams = dt.memory.get('deferApprove')

      this.$refs.search.init(this.$refs.table, new SearchOpt())
      this.$refs.table.init(this, new columnOpt(this), {
        status: retainParams?.state
      })
      this.$refs.table.fetch()
    },
    methods: {
      onFetch(data) {
        this.filterParams = { ...data }
        if (!data.status) {
          dt.memory.remove('deferApprove')
        }
        data.auditPage = true
        return extendMgr.getBoExtendList(data).then((res) => {
          this.list = res.list
          return res
        })
      },
      resetFun() {
        dt.memory.remove('deferApprove')
        this.$refs.search.init(this.$refs.table, new SearchOpt())
      },
      onSuccsse() {
        this.$refs.table.fetch()
      },
      //查看
      checkFun(row) {
        row.type = 'check'
        row.title = '延期申请详情'
        this.$refs.check.show(row)
      },
      //撤回
      approveFun(row) {
        row.type = 'approve'
        row.title = '延期申请审批'
        this.$refs.check.show(row)
      },
      onExport() {
        extendMgr.exportBoExtendList(this.filterParams)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .bonus-config {
    padding: 20px;
  }
</style>
